package com.hzlj.position.dbsync.shanxi.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
import com.fz.common.base.dto.PageParamDTO;
import com.fz.common.base.dto.QueryPageResultDTO;
import com.fz.common.base.dto.DeleteCommonDTO;
import com.fz.common.base.converter.RemoveWrapperPlus;
import com.fz.common.base.converter.QueryWrapperConverterPlus;
import com.hzlj.position.dbsync.shanxi.mapper.TSqjzDeviceMapper;
import com.hzlj.position.dbsync.shanxi.common.model.TSqjzDevice;
import com.hzlj.position.dbsync.shanxi.common.dto.tSqjzDevice.TSqjzDeviceQueryParamDTO;
import com.hzlj.position.dbsync.shanxi.common.dto.tSqjzDevice.TSqjzDeviceQueryResultDTO;

import javax.annotation.Resource;
import java.util.List;
import java.util.Date;

import cn.hutool.core.util.ObjectUtil;

/**
 * 定位设备表(TSqjzDevice)表操作类
 *
 * @author lifh
 * @date 2023-07-17 15:52:40
 */
@Repository
public class TSqjzDeviceDao extends ServiceImpl<TSqjzDeviceMapper, TSqjzDevice> {
    @Resource
    private TSqjzDeviceMapper tSqjzDeviceMapper;


    /**
     * 修改数据
     *
     * @param dto 实例对象
     * @return 实例对象
     */
    public boolean updateTSqjzDevice(TSqjzDevice dto) {
        LambdaQueryWrapper<TSqjzDevice> queryWrapper = new QueryWrapper<TSqjzDevice>().lambda()
                .eq(TSqjzDevice::getId, dto.getId());
        return this.update(dto, queryWrapper);
    }

    /**
     * 删除数据
     *
     * @param dto 实例对象
     * @return 是否成功
     */
    public boolean deleteTSqjzDevice(DeleteCommonDTO<Long> dto) {
        return RemoveWrapperPlus.remove(this, dto);
    }

    /**
     * 查询列表：不分页
     *
     * @param dto 查询条件
     * @return 对象列表
     */
    public List<TSqjzDeviceQueryResultDTO> listTSqjzDevice(TSqjzDeviceQueryParamDTO dto) {
        return QueryWrapperConverterPlus.of(tSqjzDeviceMapper)
                .list(TSqjzDeviceQueryResultDTO.class, dto);
    }

    /**
     * 查询列表：分页
     *
     * @param dto  查询条件
     * @param page 分页信息
     * @return 对象列表
     */
    public QueryPageResultDTO<TSqjzDeviceQueryResultDTO> pageTSqjzDevice(TSqjzDeviceQueryParamDTO dto, PageParamDTO page) {
        return QueryWrapperConverterPlus.of(tSqjzDeviceMapper)
                .page(TSqjzDeviceQueryResultDTO.class, dto, page);
    }
}

